import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;


public class ToolKitBar extends JFrame implements ActionListener{
	
	private int screenHeight = 0;
	private int screenWidth = 0;
	private final int HEIGHT_OFFSET = 411;
	private final int WIDTH_OFFSET = 5;
	private  TinCDCanvas canvas;
	
	private Button alkaneButton = new Button("C-C");
	private Button benzeneButton = new Button("Benzene");
	private Button alkaneChainButton = new Button("[C-C]n");
	private Button cycloHexaneButton = new Button("Cylcohexane");
	private Button textButton = new Button("Insert Text");

	
	public ToolKitBar(String toolKitName,TinCDCanvas twoDCanvas)
	{
		super(toolKitName);
		canvas = twoDCanvas;
		
		getScreenSize();
		
		this.setVisible(true);
		this.setSize(550,96);
		this.setLocation(screenWidth, screenHeight);
		this.setResizable(false);
		this.setDefaultCloseOperation(HIDE_ON_CLOSE); 
		/*NOTE!!#@@!*
		 * Make sure to have an option to bring this back if you close it!
		 */
		 setLayout(new GridLayout(3,10));
         add(alkaneButton);
         //alkaneButton.setSize(30, 30);
         add(benzeneButton);
         add(alkaneChainButton);
         add(cycloHexaneButton);
         add(textButton);

         alkaneButton.addActionListener(this);
         alkaneChainButton.addActionListener(this);
         cycloHexaneButton.addActionListener(this);
         benzeneButton.addActionListener(this);
		 textButton.addActionListener(this);
	}

	public void getScreenSize()
	{
		Toolkit javaToolKit = Toolkit.getDefaultToolkit();
		Dimension screenSize = javaToolKit.getScreenSize();
		screenHeight = screenSize.height/4+HEIGHT_OFFSET;
		screenWidth = screenSize.width/4+WIDTH_OFFSET;
		
	}
	
	public void unhideToolKit()
	{
		this.show();
}

	@Override
	public void actionPerformed(ActionEvent e) {
		
		if (e.getSource() == alkaneButton)
		{
			canvas.drawLine = true;
			canvas.drawBenzene = false;
			canvas.drawTextBox = false;
			canvas.drawChain = false;
			canvas.drawCyclohexane = false;
		}
		if(e.getSource() == alkaneChainButton)
		{
			canvas.drawLine = false;
			canvas.drawBenzene = false;
			canvas.drawTextBox = false;
			canvas.drawChain = true;
			canvas.drawCyclohexane = false;
		}
		if(e.getSource() == benzeneButton)
		{
			canvas.drawLine = false;
			canvas.drawBenzene = true;
			canvas.drawTextBox = false;
			canvas.drawChain = false;
			canvas.drawCyclohexane = false;
		}
		if(e.getSource() == cycloHexaneButton)
		{
			canvas.drawLine = false;
			canvas.drawBenzene = false;
			canvas.drawTextBox = false;
			canvas.drawChain = false;
			canvas.drawCyclohexane = true;
		}
		if(e.getSource() == textButton)
		{
			canvas.drawLine = false;
			canvas.drawBenzene = false;
			canvas.drawTextBox = true;
			canvas.drawChain = false;
			canvas.drawCyclohexane = false;
		}
			
		}
}